#include "Core\Oatmeal.h"			// standard library include (must be first include)
#include "Core\Internals.h"			// standard include for intenral definitions
#include "Core\Error.h"				// error handling routines
#include "IO\Settings.h"			// module to retrieve/set engine settings

////////////////////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////// ERROR HANDLING ROUTINES //////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////

/*/
/ / int32
/ /		ShowErrorMessage(const uint32 nTextID)
/ /
/ /		nTextID = id of the string resource to use in the message
/ /
/ / PURPOSE:
/ /		Simplify the usage of showing a message box with using resource identifiers for text.
/ /
/ / NOTES:
/ /		Assumes the resouce file belongs to the module that started the current process.
/*/

int32
ShowErrorMessage (const uint32 nTextID)
{
	int32 nReturn = 0;

	// if silent messaging is set, don't show a message box
	if(!GlobalSettings.bSilentErrors)
	{
		tchar szText[MAX_STRING] = {0};

#ifdef _WIN32
		// load the resources into our buffers and call MessageBox()
		// the caption will always be the name of the application
		if((LoadString(GlobalSettings.hEngineInstance, nTextID, szText, SIZE(szText)) > 0))
		{
			// if hWnd is NULL, make sure the type MB_TASKMODAL is specified
			// display the message and use its return value as our own
			nReturn = MessageBox(GlobalSettings.hMainWindow, szText, GlobalSettings.szAppName,
				(GlobalSettings.hMainWindow == NULL) ? MB_OK|MB_ICONERROR|MB_TASKMODAL : MB_OK|MB_ICONERROR);
		}
#endif
	}

	// zero indicates an error
	return nReturn;
}

////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////